package com.shumi.rbac.web;

import javax.servlet.http.HttpServletRequest;

import lombok.extern.slf4j.Slf4j;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.shumi.enums.StaticVarEnum;
import com.shumi.fun.WebResult;
import com.shumi.rbac.vo.TokenVO;


@RestController
@Slf4j

public class IndexController {

    @RequestMapping("/")
    public WebResult index() {
        WebResult webResult=new WebResult();
        webResult.setSuccess(true);
        webResult.setResultMsg("welcome");
        return webResult;
    }

    @RequestMapping("/api/test")
    public WebResult api(HttpServletRequest request) {
        WebResult webResult=new WebResult();
        webResult.setSuccess(true);
        webResult.setResultMsg("welcome");
        TokenVO tokenVO = (TokenVO)request.getAttribute(StaticVarEnum.TOKEN.getKey());
        return webResult;
    }


//    @RequestMapping("/api/test")
//    @ResponseBody
//    public String test(HttpServletRequest request,HttpSession session) {
//        log.info("----------------------------test-------------------------");
//        log.info("----------------sessionId:"+session.getId()+"---------------");
//        if(session.getAttribute("user")==null){
//            return "session没有进来";
//        }
//        UserVo user = (UserVo)session.getAttribute("user");
//        return user.getUsername();
//    }



}
